package day03;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
//Comparable 实现小于号 Comparator 实现临时的比较规则
public class FractionApp2 {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n=cin.nextInt();
        Fraction [] fractions=new Fraction[n];
        for (int i = 0; i < n; i++) {
            String str=cin.next();
            fractions[i]=Fraction.parsFraction(str);

        }
        Arrays.sort(fractions, new Comparator<Fraction>() {
            @Override
            public int compare(Fraction o1, Fraction o2) {
                return -1*o1.compareTo(o2);
            }
        });
        System.out.println(Arrays.asList(fractions));
    }
}
